<?
	include('Extras/Functions.php');
	CheckSession();
	
	echo("<div class='Anuncio' align='center'>");
	
	if(!empty($_POST[User]) && !empty($_POST[Pass])){ //Login attemp...
		//Conection to database
		$mysqli = ConectObj();
		
		if($result = $mysqli->query("SELECT * FROM users WHERE User = '$_POST[User]'")){ //Take data from DB
			$User = $result->fetch_object();
			
			//Check password
			if($User->Pass == $_POST[Pass]){ //If Correct Password...
				$_SESSION['s_UserID'] = $User->UserID;
				$_SESSION['s_User'] = $User->User;
				
				$IP = $_SERVER['REMOTE_ADDR'];
				$Fecha = date('Y-m-d H:i:s');
				$Logins = $User->Logins+1;
				$mysqli->query("UPDATE Users SET LLoginDate='$Fecha', LLoginIP='$IP', Logins=$Logins WHERE User = '$User->User'");
				
				echo("Bienvenido ".$_SESSION['s_User']."<br><a href='#' onclick=cCont('#SecPri','Game/Inicio.php')>Continuar</a>");
			}else{ //If incorrect password...
				echo('Usuario o contrase&ntilde;a incorrectos.');
			}
		}else{
			echo('Error No.915... Reportalo con Jesuso.');
		}
		
	}else //User and pass not recieved.
		echo('Escribe Usuario y Contrase&ntilde;a.');
	echo("</div>");
?>